<?php

namespace App\Models\Dev;

use App\Models\Constant\DevConstant;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use App\Models\Common\CommonModel;
class DevType extends CommonModel
{
    use HasFactory;

    protected $table = 'dev_type';

    protected $appends = ['business_name'];

    public function getBusinessNameAttribute(){
        return DevConstant::MAP_BUSINESS_NAME[$this->business_type]??'未知';
    }

    public function getLst(array $conditions = []){
        $records = parent::getLst($conditions); // TODO: Change the autogenerated stub
        if(!empty($conditions['business_type'])){
            $records = $records->where('business_type',$conditions['business_type']);
        }
        if(!empty($conditions['self_code'])){
            $records = $records->where('self_code',$conditions['self_code']);
        }

        return $records;
    }
}
